<script>
    function add_info() {

        var title = $("#title").val();
        var keywords = $("#keywords").val();
        var tags = $("#tags").val();
        var src_type = $("#src_type").val();
        var id_spec = $("#id_spec").val();
        var logo = $("#logo").val();
        var cnt_md = $("#cnt_md").val();
        var tag1 = $("#tag1").val();
        var tag2 = $("#tag2").val();
        var tag3 = $("#tag3").val();
        var tag4 = $("#tag4").val();
        var tag5 = $("#tag5").val();


        $.post("/post/p/add_document", {
            title: title, keywords: keywords, tags: tags,
            src_type: src_type, id_spec: id_spec, logo: logo, cnt_md: cnt_md,
            tag1: tag1,tag2: tag2,tag3: tag3,tag4: tag4,tag5: tag5

        }, function (result) {

        });
        $("#addinfo").html("添加成功");
    }


</script>
<div class="main">
    <div class="title">
        <span>添加文档</span>
    </div>

    <div class="content" id="addinfo">

        <form class="pure-form pure-form-stacked" id="form_add">

            <fieldset>
                <div class="pure-g">
                    <div class="pure-u-3-5">
                        <div class="pure-control-group">
                            <label for="title">标题</label>
                            <input id="title" type="text" name="title">
                        </div>

                        <div class="pure-control-group">
                            <label for="keywords">关键词</label>
                            <input id="keywords" name="keywords" type="text">
                        </div>
                        <div class="pure-control-group">
                            <label for="tags">标签</label>
                            <input id="tags" name="tags" type="text"/>
                        </div>
                        <div class="pure-control-group">
                            <label for="src_type">文档类型</label>
                            <select id="src_type" name="src_type">
                                <option value="0" selected>MarkDown</option>
                                <option value="1">RestructedText</option>
                            </select>
                        </div>


                        <div class="pure-control-group">
                            <label for="id_spec">所属专题</label>
                            <select id="id_spec" name="id_spec">
                                <option value="0" selected>无专题</option>
                                {% for x in kwd['specs'] %}
                                <option value="{{ x.uid }}">
                                    {{ x.name }}
                                </option>
                                {% end %}
                            </select>
                        </div>


                        <div class="pure-control-group">
                            <label for="logo">特色图片</label>
                            <input id="logo" name="logo" type="text">
                        </div>


                        <div class="pure-control-group">
                            <label for="up"></label>
                            <label id="up"><a href="/entry/add" target="_blank">上传图片</a></label>
                        </div>
                    </div>

                    <div class="pure-u-2-5">
                        {% for ii in range(1,6) %}
                        <div class="pure-control-group">
                            <label for="tag{{ii}}">分类{{ii}}</label>
                            <select name="tag{{ii}}" id="tag{{ii}}">
                                <option value="">请选择</option>
                                {% for taginfo in tag_infos %}
                                <option value="{{ taginfo.uid }}">{{ taginfo.name }}
                                </option>
                                {% end %}
                            </select>
                        </div>
                        {% end %}
                    </div>
                </div>

                <div class="pure-control-group">
                    <label for="cnt_md">内容 (下面输入内容，使用MarkDown语法)</label>
                    <textarea rows=13 id="cnt_md" name="cnt_md" cols="80"></textarea> <br/>
                </div>

                <div class="pure-control-group">
                    <label></label>
                    <button onclick="add_info()" class="pure-button pure-button-primary">添加</button>
                </div>

            </fieldset>
        </form>
    </div>

</div>
